The smallest int not less than value, rounding toward POSITIVE INFINITY - 1.1 becomes 2, and -1.1 becomes -1 (int_part would say -1 too, but int_floor would say -2).
int_ceil(value) -> int| Name | Type |
|---|---|
value | real |
int
The smallest int not less than value - rounds toward POSITIVE INFINITY, the opposite of int_floor. 1.1 becomes 2, and -1.1 becomes -1 (the same answer int_part gives there, but int_floor would say -2).
ceil rounds the same way but hands back a real instead of an int.
Use this whenever the rule is "round up, no matter what." The commonest case: how many fixed-size tiles/chunks are needed to fully cover a distance that might not divide evenly - rounding down would leave part of it uncovered.
var tile_size = 8.0;
var tiles_needed = int_ceil(37 / tile_size);37 pixels needs 5 whole 8px tiles to fully cover it, not the 4 int_part/int_floor would both give - 4 tiles is only 32 pixels, which leaves 5 pixels of the 37 uncovered.
Write 8.0, not 8. When both sides of a / are whole numbers, the answer is a whole number too: 37 / 8 is 4, with the .625 thrown away before int_ceil ever gets to see it, and int_ceil(4) is just 4. Writing 8.0 (or any number with a decimal point) makes the division keep its fraction, so int_ceil has something left to round up.
int_ceil calls the Game Boy Advance module's own round-up call for fixed-point numbers directly, the same as int_part/int_floor/int_round each call their own fixed-point call directly - a type conversion on a value GBML already treats as a raw C++ value, not a stateful engine service call.
int_floor’s own mirror image (the GBA module’s own fixed-point round-up function) - rounds up instead of down. Reach for this whenever the rule is "round up no matter what," e.g. how many 8px tiles are needed to cover a distance that might not divide evenly (int_ceil(37 / 8.0) is 5, not the 4 int_part/int_floor would both give, and a room 4 tiles wide would be 5px too narrow for a 37px sprite; write 8.0, not 8, because 37 / 8 with two whole numbers is already 4 before int_ceil ever sees it).